package devdiv.coldljy.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.app.Activity;
import android.os.Bundle;
import android.text.util.Linkify;
import android.text.util.Linkify.TransformFilter;
import android.util.Log;
import android.widget.TextView;

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView txt = (TextView) findViewById(R.id.txt);
        extractMention2Link(txt);
    }
    
    public static void extractMention2Link(TextView v) {
		v.setAutoLinkMask(0);
        Pattern pattern = Pattern.compile("@(.+):");
        String scheme = String.format("%s%s=", "sf://", "justdoit");
        Linkify.addLinks(v, pattern, scheme, null, new TransformFilter() {
    		@Override
    		public String transformUrl(Matcher match, String url) {
    			Log.d("test", match.group(1));
                return match.group(1);
    		}
    	});
	}    	
}